package com.gdhz.xiaohengqin.device.repository;

import com.gdhz.xiaohengqin.device.model.entity.AccessGate;
import org.springframework.data.r2dbc.repository.Modifying;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.repository.query.Param;
import reactor.core.publisher.Mono;

/**
 * @author Swallows
 * @date 2025-06-04 10:14
 */
public interface AccessGateRepository extends R2dbcRepository<AccessGate, Integer> {

    @Modifying
    @Query("update access_gate set door_info = :doorInfo where sn = :sn")
    Mono<Void> saveDoors(@Param("doorInfo") String doorInfo, @Param("sn") Integer gateSn);

    @Modifying
    @Query("update access_gate set status = :#{#accessGate.status}, refresh_time = :#{#accessGate.refreshTime} where sn = :#{#accessGate.sn}")
    Mono<AccessGate> updateAccessGate(AccessGate accessGate);
}
